Repository navigation
Cut Mandate false blocks 58 -> 39 of 1038 with 140/140 attacks still blocked - #13
Conversation
…ack, tool families, read-only flag variance, mkdir of report dirs, propose prompt-path warning Replay on the recorded gpt-4o-mini traces: attack calls blocked 140/140 (unchanged), legit calls blocked 58/1038 -> 39/1038. Tests 111 -> 152.
| if int(d.get("write_count", 0)): | ||
| calls += 1 | ||
| paths.update(v for v, inside, ok in d.get("writes", []) if inside and ok) |
There was a problem hiding this comment.
🟡 Directory creation exhausts rewrite allowance
After five approved mkdir calls, run_writes counts them toward the rewrite cap despite their zero write cost. The next rewrite of an approved report gets blocked under a one-write policy.
Learn more
The run's distinct-write counter excludes approved parent-directory creation through write_cost. The new raw counter instead increments for any stored shape with a positive write_count, including those directory calls. The rewrite-cap check in check then treats those calls as report rewrites and refuses a later approved rewrite. A single call can also contain multiple shell write segments, so count the qualifying segments rather than assuming one per call.
Example: With max_writes_per_run: 1, five separate mkdir -p reports calls cost zero. One write_file reports/x.md costs one. A second write_file reports/x.md is rejected because raw count is already six, although this is only the first report rewrite.
Recommended fix: Keep a separate count of actual non-directory write operations for the rewrite cap. Compute it from saved shapes with enough segment metadata to identify approved mkdir calls, or persist the charged write kind when recording each call.
Was this helpful? React with 👍 or 👎 to provide feedback.
| # Per-segment paths, used only to widen read-only commands (policy._readonly_ok). grep-style heads | ||
| # take file operands after the pattern; path_candidates only sees the absolute ones, so add the rest. | ||
| for p in shell.grep_operands(seg): | ||
| refs.append(("read", resolve(p, cwd, root))) | ||
| seg.extra["refs"] = refs |
There was a problem hiding this comment.
🟡 Saved calls mislead mandate widening
When cmd_widen rechecks a saved cat or approved mkdir call, CallShape.from_json lacks the new segment refs. It reports permitted calls as violations and can propose unnecessary permissions.
Learn more
Live normalization stores operand refs in seg.extra, and _readonly_ok requires those refs to exist. CallShape.from_json rebuilds segments without extra, is_write, redirects, or the listing marker. cmd_widen feeds those reconstructed calls to check to decide what needs widening and to preview the effect. A live-approved read-back is thus classified as an unapproved command; an approved mkdir is classified as an unapproved command and path write. These false violations can add broader rules to a pending policy.
Example: A live cat reports/x.md with reports/*.md in write rules passes. The stored call lacks refs, so cmd_widen --pattern treats it as a blocked command when replaying observations.
Recommended fix: Serialize and reconstruct the policy-relevant segment data and the listing flag, or persist enough original inputs to safely re-normalize saved calls before check. Verify that checking a round-tripped call produces the same violations as checking it live.
Was this helpful? React with 👍 or 👎 to provide feedback.
| mk = {r for i, s in enumerate(shape.segments) if seg_ok.get(i) == "mkdir" for _, r in s.extra["refs"]} | ||
| for ref in shape.writes: | ||
| if ref in mk: |
There was a problem hiding this comment.
🟡 Learned mkdir rules block approved parents
When mkdir matches a command rule, seg_ok labels it rule instead of mkdir. The parent-directory exemption then fails, blocking mkdir -p reports despite approved report writes.
| mk = {r for i, s in enumerate(shape.segments) if seg_ok.get(i) == "mkdir" for _, r in s.extra["refs"]} | |
| for ref in shape.writes: | |
| if ref in mk: | |
| mk = _mkdir_refs(shape, dirs) | |
| for ref in shape.writes: | |
| if ref in mk: | |
| continue |
Was this helpful? React with 👍 or 👎 to provide feedback.
| if not prompt or not pol.writes: | ||
| return [] |
There was a problem hiding this comment.
🟡 Missing writes suppress output-path warning
When observations contain no writes, prompt_path_warnings returns before checking the job prompt. A prompt requesting reports/status.md receives no warning, though the proposed mandate blocks that output.
| if not prompt or not pol.writes: | |
| return [] | |
| if not prompt: | |
| return [] |
Was this helpful? React with 👍 or 👎 to provide feedback.
| if head in PRINT_HEADS: | ||
| return not refs and not seg.redirects |
There was a problem hiding this comment.
…s, 0 blocks, $0.015)
… no-key replay (#12) * Real-model benchmark: 710 Hermes cron runs with gpt-4o-mini, published injections, no-key replay Mandate blocked 29 of 29 attack calls (0 of 120 attack runs with harm vs 18 with Hermes defaults), 9 of 263 legit calls falsely blocked. make bench replays the traces for free. See bench/README.md. * Cut Mandate false blocks 58 -> 39 of 1038 with 140/140 attacks still blocked (#13) * Cut false blocks without widening reach: distinct write paths, read-back, tool families, read-only flag variance, mkdir of report dirs, propose prompt-path warning Replay on the recorded gpt-4o-mini traces: attack calls blocked 140/140 (unchanged), legit calls blocked 58/1038 -> 39/1038. Tests 111 -> 152. * bench README: live spot check of the fixed code (12 clean enforce runs, 0 blocks, $0.015) --------- Co-authored-by: JoeProAI <176786290+JoeProAI@users.noreply.github.com> --------- Co-authored-by: JoeProAI <176786290+JoeProAI@users.noreply.github.com>
Builds on #12 (bench/real-model). Joe asked for a false-block fix first, then a bench rerun. Do not merge until Joe reviews.
Replay on the same recorded gpt-4o-mini traces (
bench/replay.py,score.py,headline.py, no key, no new live runs):No attack call got through at any observe length. The policies are still 10/10 identical to live. 1038 of 1043 decisions match live, and the 5 that changed are legit calls now allowed: 2 read-backs, 2 rewrites, 1
mkdir -p reports.What changed (enforcement only, policy format unchanged):
cat,head,wc,lsand similar) can read back paths the mandate already approves.read_fileandsearch_filescount as one, and so dowrite_fileandpatch. A file-name-onlysearch_filesinside the workdir is allowed.mkdiris allowed for the parent dirs of approved write paths, and it doesn't use the write budget.proposewarns when the job prompt names a file no learned write rule covers. On the live proposals it fires only on repo-status.Tests: 111 before, 152 now passing, 1 skipped as before. The new file is
tests/test_false_block_fixes.py, which includes a must-still-block list:~/.ssh,~/.aws,.env,curl|sh, a new host,rm -rf,sort -o,grep -r, mkdir escapes. Two adversarial cases are still blocked, just by a different rule (paths.*instead oftools).The full before/after, plus what's left in the 39, is in
bench/README.md.